import java.awt.Color;

public class Testcar
{
	public static void main(String[] argv)
	{
		Automobile[] fleet = new Automobile[3];
		fleet[0] = new Sedan(Color.black);
		fleet[1] = new Minivan(Color.red);
		fleet[2] = new Sportcar(Color.yellow);

		int totalcap = 0;

		for(int i = 0; i < fleet.length; i++)
		{
			if(fleet[i] instanceof Sedan)
			{
				totalcap += ((Sedan) fleet[i]).getCapacity();
			}
			else if(fleet[i] instanceof Minivan)
			{
				totalcap += ((Minivan) fleet[i]).getCapacity();
			}
			else if(fleet[i] instanceof Sportcar)
			{
				totalcap += ((Sportcar) fleet[i]).getCapacity();
			}
			else
			{
				totalcap += fleet[i].getCapacity();
			}
		}
		System.out.println("TOTAL CAP = " + totalcap);
	}
}

